<%#
 Copyright 2021-2024 sirpdboy Wich <herboy2008@gmail.com>
 https://github.com/sirpdboy/luci-app-lucky
 Licensed to the public under the Apache License 2.0.
-%>
<%
	local running = luci.sys.exec("pidof lucky | awk -F ' ' '{print $1}'")
%>

<%+header%>

<script type="text/javascript">//<![CDATA[
var URL = ""
		XHR.get('<%=url([[admin]], [[services]], [[lucky_config]])%>', null,
			function (x, d) {
				if (d) {
					URL = "http://" + window.location.hostname + ":" + d.BaseConfigure.AdminWebListenPort;
					if (d.BaseConfigure.SafeURL != undefined) {
						URL += d.BaseConfigure.SafeURL;
						
       console.log("test" + URL)
       document.getElementById("luckyiframe").src = URL
       document.getElementById("luckyiframe").height = document.documentElement.clientHeight;
       window.onresize = function(){
          document.getElementById("luckyiframe").height = document.documentElement.clientHeight;
        }
	
					}
				}
			}
		);
	
//]]></script>
<div class="cbi-map">

<% if tonumber(running) ~= nil then %>
<iframe  id="luckyiframe" style="width: 100%; min-height: 580px; border: none; border-radius: .375rem;box-shadow: rgba(0, 0, 0, 0.75) 0px 0px 15px -5px;"><br/><em style=\"color:red\">
<p ><em><%:The Lucky service is not running.%></em></p>
</iframe>

</div>
<% else %>
	<style>.running{text-align: center;} .running>h1{font-size: 25px; color: #333; margin: 1rem;} .running>p{ font-size: 1.2rem; color: #8391a2; margin: 1rem;}</style>
	<div class="running">
	<img src="" height="100">
		<h1><font color="color:red"><%:The Lucky service is not running.%></font></h1>
		<p><%:Please enable the Lucky service%></p>
    </div>
<% end -%>
</div>
<%+footer%>
